#include "BreakPointDecorator.h"

#include "BreakPointMem.h"

BreakPointDecorator::BreakPointDecorator(IBreakPoint * persist)
:persist(persist)
,loaded(false)
,mem(new BreakPointMem())
{
}

BreakPointDecorator::~BreakPointDecorator()
{
    if(mem != nullptr){
        delete mem;
        mem = nullptr;
    }

    if(persist != nullptr){
        delete persist;
        persist = nullptr;
    }
}

const long long BreakPointDecorator::get() const{
    if(loaded){
        return mem->get();
    }
    else{
        mem->set(persist->get());
        loaded = true;
        return mem->get();
    }
}
void BreakPointDecorator::set(const long long seqNo) {
    if(seqNo != mem->get()){
        mem->set(seqNo);
    }
    persist->set(seqNo);
}
void BreakPointDecorator::add(const long long step) {
    return mem->add(step);
}
